package com.dlry.entity;
// Generated 2016-10-31 13:57:37 by Hibernate Tools 3.6.0.Final

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.validator.constraints.Length;

import com.dlry.entity.validGroup.First;
import com.dlry.entity.validGroup.Second;

/**
 * DlLoginuser generated by hbm2java
 */
@Entity
@Table(name = "dl_loginuser")
public class DlLoginuser implements java.io.Serializable {

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	/**
	 * 
	 */
	@Transient
	private static final long serialVersionUID = -9152356230017964108L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private long id;
	@Column(name = "name")
	private String name;
	@Column(name = "password")
	private String password;
	@Column(name = "phone_number")
	@Length(groups = { First.class, Second.class }, message = "电话号码必须填写", max = 13, min = 8)
	private String phoneNumber;
	@Column(name = "in_email")
	private String inEmail;
	@Column(name = "enabled")
	private Boolean enabled;
	@Column(name = "created_date")
	private Timestamp createdDate;
	@Column(name = "update_date")
	private Timestamp updateDate;
	@Column(name = "real_name")
	@Length(groups = { First.class, Second.class }, message = "真名必须是1到6个汉字", max = 6, min = 1)
	private String realName;
	@Column(name = "role")
	private String roles;
	@Column(name = "level")
	private Integer level;
	@OneToMany(targetEntity = DlNotification.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "user")
	private Set<DlNotification> notifications = new HashSet<DlNotification>();
	@OneToMany(targetEntity = DlMeetingRoom.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "user")
	private Set<DlMeetingRoom> rooms = new HashSet<DlMeetingRoom>();
	@OneToMany(targetEntity = DlLeave.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "user")
	private Set<DlLeave> leaves = new HashSet<DlLeave>();
	@OneToMany(targetEntity = DlTravelRequest.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "user")
	private Set<DlTravelRequest> travels = new HashSet<DlTravelRequest>();
	@ManyToOne
	@JoinColumn(name = "branch_id")
	private DlBranch branch;
	@OneToMany(mappedBy = "hUser", targetEntity = DlLeaveflow.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	private List<DlLeaveflow> dlWorkflows;

	public void setRoles(String roles) {
		this.roles = roles;
	}

	public String getRoles() {
		return roles;
	}

	public void setBranch(DlBranch branch) {
		this.branch = branch;
	}

	public DlBranch getBranch() {
		return branch;
	}

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public DlLoginuser() {
	}

	public DlLoginuser(String name, String password, String phoneNumber, String inEmail) {
		this.name = name;
		this.password = password;
		this.phoneNumber = phoneNumber;
		this.inEmail = inEmail;
	}

	public DlLoginuser(String name, String password, String phoneNumber, String inEmail, Boolean enabled) {
		this.name = name;
		this.password = password;
		this.phoneNumber = phoneNumber;
		this.inEmail = inEmail;
		this.enabled = enabled;
	}

	public long getId() {
		return this.id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPhoneNumber() {
		return this.phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getInEmail() {
		return this.inEmail;
	}

	public void setInEmail(String inEmail) {
		this.inEmail = inEmail;
	}

	public Boolean getEnabled() {
		return this.enabled;
	}

	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}

	public Set<DlNotification> getNotifications() {
		return notifications;
	}

	public void setNotifications(Set<DlNotification> notifications) {
		this.notifications = notifications;
	}

	public Set<DlMeetingRoom> getRooms() {
		return rooms;
	}

	public Timestamp getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Timestamp createdDate) {
		this.createdDate = createdDate;
	}

	public Timestamp getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Timestamp updateDate) {
		this.updateDate = updateDate;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

	public Integer getLevel() {
		return level;
	}

	public void setRooms(Set<DlMeetingRoom> rooms) {
		this.rooms = rooms;
	}

	public Set<DlLeave> getLeaves() {
		return leaves;
	}

	public void setLeaves(Set<DlLeave> leaves) {
		this.leaves = leaves;
	}

	public Set<DlTravelRequest> getTravels() {
		return travels;
	}

	public void setTravels(Set<DlTravelRequest> travels) {
		this.travels = travels;
	}

	public List<DlLeaveflow> getDlWorkflows() {
		return this.dlWorkflows;
	}

	public void setDlWorkflows(List<DlLeaveflow> dlWorkflows) {
		this.dlWorkflows = dlWorkflows;
	}

	public DlLeaveflow addDlWorkflow(DlLeaveflow dlWorkflow) {
		getDlWorkflows().add(dlWorkflow);
		dlWorkflow.setHUser(this);

		return dlWorkflow;
	}

	public DlLeaveflow removeDlWorkflow(DlLeaveflow dlWorkflow) {
		getDlWorkflows().remove(dlWorkflow);
		dlWorkflow.setHUser(null);

		return dlWorkflow;
	}

}
